package com.shanxi.cz.module.biz.framework.mqtt.handler;

import lombok.extern.slf4j.Slf4j;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHandlingException;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class ErrorHandler {

    @ServiceActivator(inputChannel = "errorChannel")
    public void handleError(Message<?> errorMessage) {
        Throwable cause = ((MessageHandlingException) errorMessage.getPayload()).getCause();
        log.error("MQTT消息处理错误: {}", cause.getMessage(), cause);
    }
}
